<?php

namespace app\common\model;

use think\Model;

class ReservationRecord extends Model
{

    // 表名
    protected $name = 'reservation_record';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

	// 追加属性
    protected $append = [
        'daytime'
    ];
	
	public function getDaytimeAttr($value, $data)
    {
		$weekarray=array("日","一","二","三","四","五","六");
		$week = '周'.$weekarray[date('w', strtotime($data['dateinfo']))];
		
		return $data['dateinfo'].'（'.$week.'）'.$data['datetime'];
    }
	
	public function reservation()
	{
		 return $this->belongsTo('Reservation', 'pid')->setEagerlyType(0);
	}
}
